home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.3 Development Libraries / SGI IRIX 6.3 Development Libraries.iso / dist6.3 / gl_dev.idb / usr / include / gl / image.h.z / image.h
Encoding:
C/C++ Source or Header  |  1996-12-06  |  3.2 KB  |  114 lines

  1. #ifndef    __GL_IMAGE_H__
  2. #define    __GL_IMAGE_H__
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7.  
  8. /*
  9.  *    Defines for image files . . . .
  10.  *
  11.  *              Paul Haeberli - 1984
  12.  *      Look in /usr/people/4Dgifts/iristools/imgtools for example code!
  13.  *
  14.  */
  15.  
  16. #include <stdio.h>
  17.  
  18. #define IMAGIC     0732
  19.  
  20. /* colormap of images */
  21. #define CM_NORMAL        0    /* file contains rows of values which 
  22.                      * are either RGB values (zsize == 3) 
  23.                      * or greyramp values (zsize == 1) */
  24. #define CM_DITHERED        1
  25. #define CM_SCREEN        2    /* file contains data which is a screen
  26.                      * image; getrow returns buffer which 
  27.                      * can be displayed directly with 
  28.                      * writepixels */
  29. #define CM_COLORMAP        3    /* a colormap file */
  30.  
  31. #define TYPEMASK        0xff00
  32. #define BPPMASK            0x00ff
  33. #define ITYPE_VERBATIM        0x0000
  34. #define ITYPE_RLE        0x0100
  35. #define ISRLE(type)        (((type) & 0xff00) == ITYPE_RLE)
  36. #define ISVERBATIM(type)    (((type) & 0xff00) == ITYPE_VERBATIM)
  37. #define BPP(type)        ((type) & BPPMASK)
  38. #define RLE(bpp)        (ITYPE_RLE | (bpp))
  39. #define VERBATIM(bpp)        (ITYPE_VERBATIM | (bpp))
  40. #define    IBUFSIZE(pixels)    ((pixels+(pixels>>6))<<2)
  41. #define    RLE_NOP            0x00
  42.  
  43. #define    ierror(p)        (((p)->flags&_IOERR)!=0)
  44. #define    ifileno(p)        ((p)->file)
  45. #define    getpix(p)        (--(p)->cnt>=0 ? *(p)->ptr++ : ifilbuf(p))
  46. #define putpix(p,x)        (--(p)->cnt>=0 \
  47.                     ? ((int)(*(p)->ptr++=(unsigned)(x))) \
  48.                     : iflsbuf(p,(unsigned)(x)))
  49.  
  50. typedef struct {
  51.     unsigned short    imagic;        /* stuff saved on disk . . */
  52.     unsigned short     type;
  53.     unsigned short     dim;
  54.     unsigned short     xsize;
  55.     unsigned short     ysize;
  56.     unsigned short     zsize;
  57.     unsigned int     min;
  58.     unsigned int     max;
  59.     unsigned int    wastebytes;    
  60.     char         name[80];
  61.     unsigned int    colormap;
  62.  
  63.     int         file;        /* stuff used in core only */
  64.     unsigned short     flags;
  65.     short        dorev;
  66.     short        x;
  67.     short        y;
  68.     short        z;
  69.     short        cnt;
  70.     unsigned short    *ptr;
  71.     unsigned short    *base;
  72.     unsigned short    *tmpbuf;
  73.     unsigned int    offset;
  74.     unsigned int    rleend;        /* for rle images */
  75.     unsigned int    *rowstart;    /* for rle images */
  76.     int            *rowsize;    /* for rle images */
  77. } IMAGE;
  78.  
  79. IMAGE *icreate();
  80. /*
  81.  * IMAGE *iopen(char *file, char *mode, unsigned int type, unsigned int dim,
  82.  *         unsigned int xsize, unsigned int ysize, unsigned int zsize);
  83.  * IMAGE *fiopen(int f, char *mode, unsigned int type, unsigned int dim,
  84.  *         unsigned int xsize, unsigned int ysize, unsigned int zsize);
  85.  *
  86.  * ...while iopen and fiopen can take an extended set of parameters, the 
  87.  * last five are optional, so a more correct prototype would be:
  88.  *
  89.  * IMAGE *iopen(char *file, char *mode, ...);
  90.  * IMAGE *fiopen(int f, char *mode, ...);
  91.  * 
  92.  * unsigned short *ibufalloc(IMAGE *image);
  93.  * int ifilbuf(IMAGE *image);
  94.  * int iflush(IMAGE *image);
  95.  * unsigned int iflsbuf(IMAGE *image, unsigned int c);
  96.  * void isetname(IMAGE *image, char *name);
  97.  * void isetcolormap(IMAGE *image, int colormap);
  98.  * int iclose(IMAGE *image);
  99.  * 
  100.  * int putrow(IMAGE *image, unsigned short *buffer, unsigned int y, unsigned int z);
  101.  * int getrow(IMAGE *image, unsigned short *buffer, unsigned int y, unsigned int z);
  102.  * 
  103.  */
  104.  
  105. IMAGE *iopen();
  106. IMAGE *icreate();
  107. unsigned short *ibufalloc();
  108.  
  109. #define IMAGEDEF        /* for backwards compatibility */
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113. #endif    /* !__GL_IMAGE_H__ */
  114.